//
// Created by liushuai on 2021/2/21.
//

#include "findMaxConsecutiveOnes.h"
int findMaxConsecutiveOnes(vector<int>& nums) {
    int start = 0;
    int end = 0;
    int max_count = 0;
    while (end<nums.size()){
        if(nums[end] == 1){
            ++end;
        }else{
            while (end<nums.size()&&nums[end]==0)
                end++;
            start = end;
        }
        if(end-start>max_count)
            max_count = end-start;
    }
    return max_count;
}